let uiWaitTime = 1000;
function clickUI(item, waitTime) {
    if (item) {
        if (item.clickable()) {
            item.click();
        } else {
            click(item.bounds().centerX(), item.bounds().centerY());
        }
        if (waitTime && waitTime > 0) {
            // console.log('睡眠' + waitTime)
            sleep(waitTime);
        }
    } else {
        console.warn("UI控件为空，无法点击");
    }
}
function __openZfbScan__() {
    try {
        let uri = app.parseUri("alipayqr://platformapi/startapp?saId=10000007");
        let intent = new Intent(Intent.ACTION_VIEW, uri);
        app.startActivity(intent);
        sleep(1000);
    } catch (e) {
        console.trace(e);
    }
}
function __selectPicture__() {
    let btn = text('相册').findOne();
    clickUI(btn, uiWaitTime);
    btn = text('系统相册').findOne();
    clickUI(btn, uiWaitTime);
    btn = text('相册').find()[1];
    clickUI(btn, uiWaitTime);
    btn = text('收藏').findOne();
    clickUI(btn, uiWaitTime);
    btn = className('android.widget.ImageView').find()[1];
    clickUI(btn, uiWaitTime);
}

function run() {
    __openZfbScan__();
    __selectPicture__();
}
run();
